home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / file / managers / mc-3.2 / mc-3 / mc-3.2.1 / src / util.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-17  |  3.7 KB  |  154 lines

  1. #ifndef __UTIL_H
  2. #define __UTIL_H
  3.  
  4.  
  5. #include <sys/types.h>
  6.  
  7. /* String managing functions */
  8.  
  9. int is_printable (int c);
  10. int msglen (char *text, int *lines);
  11. char *trim (char *s, char *d, int len);
  12. char *name_trunc (char *txt, int trunc_len);
  13. char *size_trunc (long int size);
  14. char *size_trunc_sep (long int size);
  15. int is_exe (mode_t mode);
  16. char *string_perm (mode_t mode_bits);
  17. char *strip_home(char *dir);
  18. char *extension (char *);
  19. char *split_extension (char *, int pad);
  20. char *get_full_name (char *dir, char *file);
  21. char *copy_strings (char *first, ...);
  22. char *unix_error_string (int error_num);
  23. char *skip_separators (char *s);
  24. char *skip_numbers (char *s);
  25. char *strip_ctrl_codes (char *s);
  26. char *convert_controls (char *s);
  27. void wipe_password (char *passwd);
  28. char *reverse_string (char *string);
  29. char *resolve_symlinks (char *path);
  30. char *diff_two_paths (char *first, char *second);
  31.  
  32. #ifndef HAVE_STRCASECMP
  33. int strcasecmp (char *s, char *d);
  34. #endif
  35.  
  36. char *x_basename (char *s);
  37.  
  38. extern int align_extensions;
  39. #ifndef HAVE_MAD
  40. void *do_xmalloc (int);
  41. #define xmalloc(a,b) do_xmalloc (a)
  42. #endif
  43.  
  44. /* Profile managing functions */
  45. int set_int (char *, char *, int);
  46. int get_int (char *, char *, int);
  47.  
  48. char *load_file (char *filename);
  49.  
  50. #include "fs.h"
  51. #ifndef S_ISLNK
  52. #   define S_ISLNK(x) (((x) & S_IFLNK) == S_IFLNK)
  53. #endif
  54.  
  55. #ifndef S_ISSOCK
  56. #   ifdef S_IFSOCK
  57. #       define S_ISSOCK(x) (((x) & S_IFSOCK) == S_IFSOCK)
  58. #   else
  59. #       define S_ISSOCK(x) 0
  60. #   endif
  61. #endif
  62.  
  63. /* uid/gid managing */
  64. void init_uid_gid_cache (void);
  65. char *get_group (int);
  66. char *get_owner (int);
  67.  
  68. char *file_date (time_t);
  69. char *file_date_pck (time_t);
  70. int exist_file (char *name);
  71.  
  72. /* Returns a copy of *s until a \n is found and is below top */
  73. char *extract_line (char *s, char *top);
  74. char *icase_search (char *text, char *data);
  75.  
  76. /* Matching */
  77. enum { match_file, match_normal };
  78. extern int easy_patterns;
  79. char *convert_pattern (char *pattern, int match_type, int do_group);
  80. int regexp_match (char *pattern, char *string, int match_type);
  81.  
  82. /* Error pipes */
  83. void open_error_pipe (void);
  84. void check_error_pipe (void);
  85. void close_error_pipe (int error, char *text);
  86.  
  87. /* Process spawning */
  88. void my_putenv (char*, char*);
  89. int my_system (int as_shell_command, const char *shell, const char *command);
  90. void save_stop_handler (void);
  91. extern struct sigaction startup_handler;
  92.  
  93. /* Tilde expansion */
  94. char *tilde_expand (char *);
  95.  
  96. /* Pathname canonicalization */
  97. char *canonicalize_pathname (char *);
  98.  
  99. /* Misc Unix functions */
  100. long blocks2kilos (int blocks, int bsize);
  101. char *get_current_wd (char *buffer, int size);
  102. int my_mkdir (char *s, mode_t mode);
  103. int my_rmdir (char *s);
  104.  
  105. /* Filesystem status */
  106. struct my_statfs {
  107.     int type;
  108.     char *typename;
  109.     char *mpoint;
  110.     char *device;
  111.     int avail;
  112.     int total;
  113.     int nfree;
  114.     int nodes;
  115. };
  116.  
  117. void init_my_statfs (void);
  118. void my_statfs (struct my_statfs *myfs_stats, char *path);
  119.  
  120. /* Rotating dash routines */
  121. void use_dash (int flag); /* Disable/Enable rotate_dash routines */
  122. void rotate_dash (void);
  123. void remove_dash (void);
  124.  
  125. extern char app_text [];
  126.  
  127. long int is_gunzipable (int fd);
  128.  
  129. int mc_doublepopen (int inhandle, int inlen, pid_t *tp, char *command, ...);
  130. int mc_doublepclose (int pipehandle, pid_t pid);
  131.  
  132. /* Hook functions */
  133.  
  134. typedef struct hook {
  135.     void (*hook_fn)(void *);
  136.     void *hook_data;
  137.     struct hook *next;
  138. } Hook;
  139.  
  140. void add_hook (Hook **hook_list, void (*hook_fn)(void *), void *data);
  141. void execute_hooks (Hook *hook_list);
  142. void delete_hook (Hook **hook_list, void (*hook_fn)(void *));
  143. int hook_present (Hook *hook_list, void (*hook_fn)(void *));
  144.  
  145. #ifndef _OS_NT
  146. #define PATH_SEP '/'
  147. #define PATH_SEP_STR "/"
  148. #else
  149. #define PATH_SEP '\\'
  150. #define PATH_SEP_STR "\\"
  151. #endif
  152.  
  153. #endif
  154.